package com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.common.ToolKit;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.FaWenInfo;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.bo.ITXingzhengshouwenNeirongBO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.vo.ShouWenInfo;
import com.tjsinfo.tjsoa.system.bo.ISystemUserBo;

public class ShouWenAdminAction extends Action{
	private ITXingzhengshouwenNeirongBO xingzhengshouwenNeirongBO;
	private ISystemUserBo systemUserBo;
	
	
	public ISystemUserBo getSystemUserBo() {
		return systemUserBo;
	}
	public void setSystemUserBo(ISystemUserBo systemUserBo) {
		this.systemUserBo = systemUserBo;
	}
	public ITXingzhengshouwenNeirongBO getXingzhengshouwenNeirongBO() {
		return xingzhengshouwenNeirongBO;
	}
	public void setXingzhengshouwenNeirongBO(
			ITXingzhengshouwenNeirongBO xingzhengshouwenNeirongBO) {
		this.xingzhengshouwenNeirongBO = xingzhengshouwenNeirongBO;
	}
	
	

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		Integer xingzhengduty = 0;
		Integer dangweiduty = 0;
		Integer userid=SessionUser.getUserId(request);
		if (systemUserBo.isUserDuty(userid, "办公室主管")) {
			xingzhengduty = 1;
		}
		if (systemUserBo.isUserDuty(userid, "党办主管")) {
			dangweiduty = 1;
		}
		request.setAttribute("xingzhengduty", xingzhengduty);
		request.setAttribute("dangweiduty", dangweiduty);
		List<ShouWenInfo> newlist = new ArrayList<ShouWenInfo>(); 
		List<ShouWenInfo> bangongshipibanlist = new ArrayList<ShouWenInfo>(); 
		List<ShouWenInfo> dangbanpibanlist = new ArrayList<ShouWenInfo>();
		List<ShouWenInfo> bumennibanlist = new ArrayList<ShouWenInfo>(); 
		List<ShouWenInfo> lingdaopibanlist = new ArrayList<ShouWenInfo>(); 
		List<ShouWenInfo> bumenchengbanlist = new ArrayList<ShouWenInfo>(); 
		List<ShouWenInfo> chuanyuelist = new ArrayList<ShouWenInfo>(); 
		List<ShouWenInfo> dengjixiugailist = new ArrayList<ShouWenInfo>(); 
		
		List<ShouWenInfo> listall = xingzhengshouwenNeirongBO.selectDaibanTask(userid);
		
		for(int i=0; i<listall.size();i++){
			ShouWenInfo shouweninfo = listall.get(i);
			String huanjie=shouweninfo.getNodename();
			if("办公室主任批办".equals(huanjie)){
				if ("dangweishouwen".equals(shouweninfo.getTableName())){
					dangbanpibanlist.add(shouweninfo);
				}else{
					bangongshipibanlist.add(shouweninfo);
				}
			}else if("承办部门拟办".equals(huanjie)){
				bumennibanlist.add(shouweninfo);
			}else if("领导批办".equals(huanjie)){
				lingdaopibanlist.add(shouweninfo);
			}else if("承办部门承办".equals(huanjie)){
				bumenchengbanlist.add(shouweninfo);
			}else if("传阅".equals(huanjie)){
				chuanyuelist.add(shouweninfo);
			}else if("登记修改".equals(huanjie)){
				dengjixiugailist.add(shouweninfo);
			}
		}
		
		List<ShouWenInfo> banlizhonglist = new ArrayList<ShouWenInfo>();
		
		//if(systemUserBo.isUserPost(userid, "收文办理追踪人")){
			banlizhonglist = xingzhengshouwenNeirongBO.selectShouWenBanLiZhongTask(userid);
	//	}
		request.setAttribute("bangongshipibanlist", bangongshipibanlist);
		request.setAttribute("dangbanpibanlist", dangbanpibanlist);
		request.setAttribute("bumennibanlist", bumennibanlist);
		request.setAttribute("lingdaopibanlist", lingdaopibanlist);
		if(systemUserBo.isUserDuty(userid, "办公室主任") ||systemUserBo.isUserDuty(userid, "党办主任")){
			request.setAttribute("bumenchengbanlist", newlist);
			request.setAttribute("bangongshichuanyue",bumenchengbanlist);
		}else{
			request.setAttribute("bumenchengbanlist", bumenchengbanlist);
			request.setAttribute("bangongshichuanyue",newlist);
		}
		request.setAttribute("chuanyuelist", chuanyuelist);
		request.setAttribute("dengjixiugailist", dengjixiugailist);
		request.setAttribute("banlizhonglist", banlizhonglist);

		return mapping.findForward("ok");
	}
	
}


